package Year22_Month01.day0126;

public class Solution {
    public boolean isHappy(int n) {
        int key = n;
        for(int i = 100;i > 0;i--){
            int res = 0;
            while(key != 0){
                if( key / 10 != 0){
                    res += Math.pow(key % 10,2);
                    key /= 10;
                }else {
                    break;
                }
            }
            key = res;
            if(key == 1){
                return true;
            }
        }
        return false;
    }
}
